gl overleaf "$dropbox/Apps/Overleaf/OptimalMobileRegulation"
cap cd "$dropbox/optimal_mobile_regulation"


set excelxlsxlargefile on
version 15.1
est clear

cap pr drop sampleSelectionDD
pr de sampleSelectionDD
	keep if model_year >= 1982 & model_year <= 2003
	keep if emissions_used_CO < . & emissions_used_HC < . & emissions_used_NOX < . 
	cap keep if age >= 4 & age <= 40
	
	* first test in IM240 test cycle
	cap keep if v_test == 1 

	* non-missing odometer reading
	cap keep if odometer < .

	*-------------------------- define additional variables -----------------------*
	foreach v of varlist emissions_used_* standard_CO standard_HC standard_NOX {
		g ln`v' = ln(`v')
	}

	cap g age5    = age >= 4 & age <= 6 
	cap replace age5 = 0 if odometer < 40000 | (odometer > 60000 & odometer < .)

	cap g age_2 = age ^ 2

	cap replace odometer = odometer / 100000
	cap g odometer_2 = odometer ^ 2
end

